package com.gitee.leijin.rbac.config;

import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.gitee.leijin.rbac.config.properties.AuthorizationProperties;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {


    /**
     * 定制ObjectMapper
     */
    @Bean
    public Jackson2ObjectMapperBuilderCustomizer objectMapperBuilderCustomizer() {
        return jacksonObjectMapperBuilder -> {
            // Long类型序列化为字符串，避免丢失精度
            jacksonObjectMapperBuilder.serializerByType(Long.class, ToStringSerializer.instance);
            // long类型序列化为字符串，避免丢失精度
            jacksonObjectMapperBuilder.serializerByType(Long.TYPE, ToStringSerializer.instance);
        };
    }
}
